package ch11;

import java.sql.*;

public class Population {
    public static void main(String args[]){
        Connection con=null;
        Statement sql;
        ResultSet rs;
        try{  Class.forName("com.mysql.jdbc.Driver");
        }
        catch(Exception e){}
        String uri = "jdbc:mysql://localhost:3306/world?useSSL=true";
        String user ="root";
        String password ="";
        try{
            con = DriverManager.getConnection(uri,user,password);
        }
        catch(SQLException e){ }
        try {
            sql = con.createStatement();
            rs = sql.executeQuery("SELECT * FROM city");
            while(rs.next()){
                int id = rs.getInt(1);
                String name = rs.getString(2);
                int pop = rs.getInt(5);
                if(pop>=9016520){                               //根据20165207比较人口大于等于9016520
                    System.out.println(name);
                }
                System.out.println(name);
            }
        }
        catch (SQLException e){
            System.out.println(e);
        }
    }
}
